package com.spider.dao.hbase;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;

public class Test {
	public static void main(String[] args) throws Exception {
		HBaseDao dao = new HBaseDAOImp();
		String tableName="testtable";
		String[] cfs= {"cf1","cf2"};
		dao.create(tableName,cfs);
//		List<Put> list = new ArrayList<Put>();
//		System.out.println(new Date());
//		for (int i = 0; i < 2; i++) {
//			Put put = new Put(("r234" + i).getBytes());
//			put.add("cf1".getBytes(), "34".getBytes(), ("����" + i).getBytes());
//			put.setWriteToWAL(false);
//			list.add(put);
//			dao.save(put, tableName) ;
//		}
		//dao.save(list, tableName);
		
//		Put put =new Put(Bytes.toBytes("cf"));
//		put.add("cf1".getBytes(), "addr".getBytes(), "shanghai1".getBytes()) ;
//		list.add(put) ;
//		put.add("cf1".getBytes(), "age".getBytes(), "30".getBytes()) ;
//		list.add(put) ;
//		put.add("cf1".getBytes(), "tel".getBytes(), "13567882341".getBytes()) ;
//		list.add(put) ;
//		
//		dao.save(list,tableName);
//		dao.save(put,tableName); 
//		dao.insert(tableName, "testrow", "cf1", "age", "35") ;
//		dao.insert(tableName, "testrow", "cf1", "cardid", "12312312335") ;
//		dao.insert(tableName, "testrow", "cf1", "tel", "13512312345") ;
//	//	List<Result> lists = dao.getRows("test", "r23419",new String[]{"name"}) ;

		List<Result> list = dao.getRows(tableName, "r234198","r2341996") ;
		for(Result rs : list)
		{
			for(KeyValue keyValue : rs.raw())
			{
				System.out.println("rowkey:"+ new String(keyValue.getRow()));
				System.out.println("Qualifier:"+ new String(keyValue.getQualifier()));
				System.out.println("Value:"+ new String(keyValue.getValue()));
				System.out.println("----------------");
			}
		}

	}
}